package cn.ecut.reflection;

/**
 * @Author ruanxin
 */
public class Test04 {
    public static void main(String[] args) throws ClassNotFoundException {

        //获取系统类的加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //获取系统类加载器的父类---->扩展加载器
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);

        //获取扩展加载器的父类--->根加载器(c/c++)
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);

        //测试当前类是哪个类加载器加载
        ClassLoader classLoader = Class.forName("cn.ecut.reflection.Test04").getClassLoader();
        System.out.println(classLoader);

        //测试JDK内置类是由谁加载
        classLoader = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(classLoader);

        //如何获取系统类加载器可以加载的路径
        System.out.println(System.getProperty("java.class.path"));
        /*
        E:\jdk1.8.0_261\jre\lib\charsets.jar;
        E:\jdk1.8.0_261\jre\lib\deploy.jar;
        E:\jdk1.8.0_261\jre\lib\ext\access-bridge-64.jar;
        E:\jdk1.8.0_261\jre\lib\ext\cldrdata.jar;
        E:\jdk1.8.0_261\jre\lib\ext\dnsns.jar;
        E:\jdk1.8.0_261\jre\lib\ext\jaccess.jar;
        E:\jdk1.8.0_261\jre\lib\ext\jfxrt.jar;
        E:\jdk1.8.0_261\jre\lib\ext\localedata.jar;
        E:\jdk1.8.0_261\jre\lib\ext\nashorn.jar;
        E:\jdk1.8.0_261\jre\lib\ext\sunec.jar;
        E:\jdk1.8.0_261\jre\lib\ext\sunjce_provider.jar;
        E:\jdk1.8.0_261\jre\lib\ext\sunmscapi.jar;
        E:\jdk1.8.0_261\jre\lib\ext\sunpkcs11.jar;
        E:\jdk1.8.0_261\jre\lib\ext\zipfs.jar;
        E:\jdk1.8.0_261\jre\lib\javaws.jar;
        E:\jdk1.8.0_261\jre\lib\jce.jar;
        E:\jdk1.8.0_261\jre\lib\jfr.jar;
        E:\jdk1.8.0_261\jre\lib\jfxswt.jar;
        E:\jdk1.8.0_261\jre\lib\jsse.jar;
        E:\jdk1.8.0_261\jre\lib\management-agent.jar;
        E:\jdk1.8.0_261\jre\lib\plugin.jar;
        E:\jdk1.8.0_261\jre\lib\resources.jar;
        E:\jdk1.8.0_261\jre\lib\rt.jar;
        D:\IdeaProjects\annotation\out\production\annotation;
        D:\IntelliJ IDEA 2020.3\lib\idea_rt.jar*/
    }
}
